﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;

namespace USM_Presenter.ViewModels
{
    [Serializable()]
    [XmlInclude(typeof(ImageViewModel))]
    [XmlInclude(typeof(VideoViewModel))]
    public abstract class ThumbElementBase : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        protected void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(info));
        }

        #endregion

        public enum FileTypeEnum { Image, Video }
        protected FileTypeEnum _fileType;
        public FileTypeEnum FileType { get { return _fileType; } }

        protected PageViewModel _parent;
        [XmlIgnore]
        public PageViewModel Parent
        {
            get { return _parent; }
            set { _parent = value; }
        }

        protected Guid _primaryID = Guid.NewGuid();
        public Guid PrimaryID
        {
            get { return _primaryID; }
            set { _primaryID = value; }
        }

        protected string _path;
        public string Path
        {
            get { return _path; }
            set
            {
                if (_path != value)
                {
                    _path = value;
                    NotifyPropertyChanged("Path");
                }
            }
        }

        protected string _text;
        public string Text
        {
            get { return _text; }
            set
            {
                if (_text != value)
                {
                    _text = value;
                    NotifyPropertyChanged("Text");
                }
            }
        }

        protected bool _isOnCanvas;
        [XmlIgnore]
        public bool IsOnCanvas
        {
            get { return _isOnCanvas; }
            set
            {
                if (value != _isOnCanvas)
                {
                    _isOnCanvas = value;
                    NotifyPropertyChanged("IsOnCanvas");
                    NotifyPropertyChanged("IsNotOnCanvas");
                }
            }
        }

        public bool IsNotOnCanvas { get { return !IsOnCanvas; } }

        public bool IsVideo { get { return _fileType == FileTypeEnum.Video; } }
    }
}